<div ms-controller="editor" ms-if="fields.length>0">
    <form class="am-form am-form-horizontal am-form-group-sm">
        <div class="am-form-group">
            <label for="doc-ipt-3" class="am-u-sm-2 am-form-label">字段名</label>
            <div class="am-u-sm-7">
                <input type="text" id="doc-ipt-3" ms-duplex="fields[eindex].name" >
            </div> <div class="am-u-sm-3 am-text-xs"></div>
        </div>

        <div class="am-form-group">
            <label for="doc-ipt-pwd-2" class="am-u-sm-2 am-form-label">字段描述</label>
            <div class="am-u-sm-7">
                <input type="text" id="doc-ipt-pwd-2"  ms-duplex="fields[eindex].comment">
            </div>
            <div class="am-u-sm-3 am-text-xs"></div>
        </div>
        <div class="am-form-group">
            <label class="am-u-sm-2 am-form-label">字段类型</label>
            <div class="am-u-sm-7">
                <input type="text" ms-duplex="fields[eindex].type" id="type" >
                <div class="am-text-left am-padding-top-sm">
                    <button type="button" ms-click="chooseType('STRING(255)')" class="am-btn am-btn-primary am-btn-xs">STRING(255)</button>
                    <button type="button" ms-click="chooseType('CHAR(30)')" class="am-btn am-btn-primary am-btn-xs">CHAR(30)</button>
                    <button type="button" ms-click="chooseType('TEXT')" class="am-btn am-btn-primary am-btn-xs">TEXT</button>
                    <!--<button type="button" ms-click="chooseType('TEXT(medium)')" class="am-btn am-btn-primary am-btn-xs">TEXT(medium)</button>-->
                    <!--<button type="button" ms-click="chooseType('TEXT(long)')" class="am-btn am-btn-primary am-btn-xs">TEXT(long)</button>-->
                    <button type="button" ms-click="chooseType('INTEGER(20)')" class="am-btn am-btn-primary am-btn-xs">INTEGER(20)</button>
                    <button type="button" ms-click="chooseType('INTEGER(20).UNSIGNED')" class="am-btn am-btn-primary am-btn-xs">INTEGER(20).UNSIGNED</button>
                    <button type="button" ms-click="chooseType('BIGINT(20)')" class="am-btn am-btn-primary am-btn-xs">BIGINT(20)</button>
                    <button type="button" ms-click="chooseType('FLOAT(20)')" class="am-btn am-btn-primary am-btn-xs">FLOAT(20)</button>
                    <button type="button" ms-click="chooseType('FLOAT(11,12)')" class="am-btn am-btn-primary am-btn-xs">FLOAT(11,12)</button>
                    <button type="button" ms-click="chooseType('JSON')" class="am-btn am-btn-primary am-btn-xs">JSON</button>
                    <button type="button" ms-click="chooseType('NOW')" class="am-btn am-btn-primary am-btn-xs">NOW</button>
                    <button type="button" ms-click="chooseType('DATE')" class="am-btn am-btn-primary am-btn-xs">DATE</button>
                    <button type="button" ms-click="chooseType('BOOLEAN')" class="am-btn am-btn-primary am-btn-xs">BOOLEAN</button>
                </div>
            </div> <div class="am-u-sm-3 am-text-xs">sequelizejs字段类型</div>
        </div>
        <div class="am-form-group">
            <label class="am-u-sm-2 am-form-label">允许为空</label>
            <div class="am-u-sm-7">
                <select ms-duplex-boolean="fields[eindex].allowNull">
                    <option value="false">否</option>
                    <option value="true">是</option>
                </select>
            </div> <div class="am-u-sm-3 am-text-xs"></div>
        </div>
        <div class="am-form-group">
            <label class="am-u-sm-2 am-form-label">是否唯一</label>
            <div class="am-u-sm-7">
                <select ms-duplex-boolean="fields[eindex].unique">
                    <option value="false">否</option>
                    <option value="true">是</option>
                </select>
            </div> <div class="am-u-sm-3 am-text-xs"></div>
        </div>
        <div class="am-form-group">
            <label class="am-u-sm-2 am-form-label">默认值</label>
            <div class="am-u-sm-7">
                <input type="text"  ms-duplex="fields[eindex].defaultValue">
            </div> <div class="am-u-sm-3 am-text-xs">注意：Mysql text，json等类型不允许有默认值，请置空</div>
        </div>
        <div class="am-form-group">
            <label class="am-u-sm-2 am-form-label">验证规则</label>
            <div class="am-u-sm-7">
                <input type="text" ms-duplex="fields[eindex].validate.rule" >
            </div> <div class="am-u-sm-3 am-text-xs">写法参加</div>
        </div>
        <div class="am-form-group">
            <label class="am-u-sm-2 am-form-label">错误提示</label>
            <div class="am-u-sm-7">
                <input type="text" ms-duplex="fields[eindex].validate.error" >
            </div> <div class="am-u-sm-3 am-text-xs">验证失败后的提示</div>
        </div>
        <div class="am-form-group">
            <div class="am-u-sm-12">
                <button type="button" ms-click="add" class="am-btn  am-btn-success">保存</button>
            </div>
        </div>
    </form>

</div>
<script>

    var editor=avalon.define({
        $id:'editor',
        chooseType:function(str){
            document.getElementById('type').value=str;
            //avalon.vmodels['app'].fields[avalon.vmodels['app'].eindex].type=str;
        },
        add:function(){
            $('#doc-modal-2').modal('close');
        }
    });


</script>